class Dog:
    """一次模拟小狗的简单尝试"""

    def __init__(self, name, age, color='灰色'):
        """初始化属性name和age。"""
        self.name = name
        self.age = age
        self.color = color
        print("_init__(self, 形参, 形参，...)类里面的固定方法")

    def sit(self):
        """模拟小狗收到命令时蹲下"""
        print(f"{self.name} is now sitting.")

    def roll_over(self):
        """模拟小狗收到命令时打滚。"""
        print(f"{self.name} rolled over!")

    def run(self, color):
        """模拟小狗收到命令时跑"""
        self.color = color  # 在方法中修改属性值
        print(f"{self.name} is {color}")


if __name__ == '__main__':
    print(__name__ == '__main__')
    my_dog = Dog("小黄", 4)
    print(my_dog.name, my_dog.age, my_dog.color)
    my_dog.sit()
    my_dog.roll_over()
    my_dog.run('白色')


class Small_dog(Dog):
    """
    子类继承父类
    """
    def __init__(self, name, age):
        """
        初始化父类的属性
        再初始化自己特有属性：where
        :param name:
        :param age:
        """
        super().__init__(name, age)
        self.where = '亚洲'

    def form(self):
        """
        子类特方法
        :return:
        """
        print(self.name, '来自：', self.where)


if __name__ == '__main__':
    my_dog = Small_dog('小白', 2)
    my_dog.sit()  # 使用父类方法
    my_dog.form()